home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Examples / SimpleContainer / UContainerDocument.cp < prev    next >
Encoding:
Text File  |  1996-04-03  |  6.6 KB  |  209 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UContainerDocument.cp
  3. // Copyright © 1996 by Apple Computer, Inc. All rights reserved. 
  4. //----------------------------------------------------------------------------------------
  5.  
  6. #ifndef __UContainerDocument__
  7. #include "UContainerDocument.h"
  8. #endif
  9.  
  10.  
  11. #ifndef __UODPARTVIEW__
  12. #include "UODPartView.h"
  13. #endif
  14.  
  15. #ifndef __UCONTAINER__
  16. #include "UContainer.h"
  17. #endif
  18.  
  19. // MacApp
  20.  
  21. #ifndef __UMACAPPGLOBALS__
  22. #include "UMacAppGlobals.h"
  23. #endif
  24.  
  25. #ifndef __UMENUMGR__
  26. #include "UMenuMgr.h"
  27. #endif
  28.  
  29. #ifndef __UPRINTING__
  30. #include "UPrinting.h"
  31. #endif
  32.  
  33. #ifndef __UVIEWSERVER__
  34. #include "UViewServer.h"
  35. #endif
  36.  
  37. #ifndef __UWINDOW__
  38. #include "UWindow.h"
  39. #endif
  40.  
  41. //----------------------------------------------------------------------------------------
  42. // Constants:
  43. //----------------------------------------------------------------------------------------
  44. // Static initialization
  45.  
  46. const ResNumber kContainerWindowID = kDefaultWindowID;
  47.  
  48. //========================================================================================
  49. // CLASS TContainerDocument
  50. //========================================================================================
  51. #undef Inherited
  52. #define Inherited TFileBasedDocument
  53.  
  54. #pragma segment AOpen
  55. MA_DEFINE_CLASS_M1(TContainerDocument, Inherited);
  56.  
  57. //----------------------------------------------------------------------------------------
  58. // TContainerDocument constructor 
  59. //----------------------------------------------------------------------------------------
  60. #pragma segment AOpen
  61.  
  62. TContainerDocument::TContainerDocument()
  63.             :fODPartView(NULL) 
  64. {
  65. } // TContainerDocument::TContainerDocument 
  66.  
  67. //----------------------------------------------------------------------------------------
  68. // TContainerDocument::IContainerDocument: 
  69. //----------------------------------------------------------------------------------------
  70. #pragma segment AOpen
  71.         
  72. void TContainerDocument::IContainerDocument(TFile* itsFile,
  73.                                           OSType itsCreator)
  74. {
  75.     this->IFileBasedDocument(itsFile,itsCreator);
  76. } // TContainerDocument::IContainerDocument 
  77.  
  78. //----------------------------------------------------------------------------------------
  79. // TContainerDocument destructor
  80. //----------------------------------------------------------------------------------------
  81. #pragma segment AClose
  82.  
  83. TContainerDocument::~TContainerDocument()
  84. {
  85. }
  86.  
  87. //----------------------------------------------------------------------------------------
  88. // TContainerDocument::FreeData: 
  89. //----------------------------------------------------------------------------------------
  90. #pragma segment AClose
  91.  
  92. void TContainerDocument::FreeData() // Override 
  93. {
  94.     Inherited::FreeData();
  95. } // TContainerDocument::FreeData 
  96.  
  97. //----------------------------------------------------------------------------------------
  98. // TContainerDocument::DoInitialState: 
  99. //----------------------------------------------------------------------------------------
  100. #pragma segment AOpen
  101.  
  102. void TContainerDocument::DoInitialState() // Override 
  103. {
  104.     Inherited::DoInitialState();
  105. } // TContainerDocument::DoInitialState 
  106.  
  107. //----------------------------------------------------------------------------------------
  108. // TContainerDocument::DoMakeViews: 
  109. //----------------------------------------------------------------------------------------
  110. #pragma segment AOpen
  111.  
  112. void TContainerDocument::DoMakeViews(Boolean /*forPrinting*/) // Override 
  113. {
  114.     TWindow* aWindow = NULL;
  115.  
  116.  
  117.     FailNIL(aWindow = gViewServer->NewTemplateWindow(kContainerWindowID, this));
  118.  
  119.     fODPartView         = (TODPartView*) (aWindow->FindSubView('odPT'));
  120.     fFrameRadioButton     = (TRadio*) (aWindow->FindSubView('adFR'));
  121.     fViewRadioButton     = (TRadio*) (aWindow->FindSubView('adVW'));
  122.  
  123.     
  124. #if qContainer
  125.         if (gContainerLib && fContainerDocument)
  126.         {
  127.             fRootWindowRef = aWindow->fWMgrWindow;
  128.             CARegisterRootWindow(fRootWindowRef, fContainerDocument);
  129.             FailOSErr(CAError());
  130.         }
  131. #endif
  132. } // TContainerDocument::DoMakeViews 
  133.  
  134. //----------------------------------------------------------------------------------------
  135. // TContainerDocument::CloseWindow: 
  136. //----------------------------------------------------------------------------------------
  137. #pragma segment MAClose
  138.  
  139. void TContainerDocument::CloseWindow(TWindow* aWindow) // override
  140. {
  141. #if qContainer
  142.     if (aWindow->fWMgrWindow == fRootWindowRef)
  143.     {
  144.         CAUnregisterWindow(fRootWindowRef);
  145.         fRootWindowRef = NULL;
  146.     }
  147. #endif
  148.     Inherited::CloseWindow(aWindow);
  149. }
  150.  
  151. //----------------------------------------------------------------------------------------
  152. // TContainerDocument::DoNeedDiskSpace: 
  153. //----------------------------------------------------------------------------------------
  154. #pragma segment AWriteFile
  155.  
  156. void TContainerDocument::DoNeedDiskSpace(TFile* itsFile,
  157.                                         long& dataForkBytes,
  158.                                         long& rsrcForkBytes) // Override 
  159. {
  160.     Inherited::DoNeedDiskSpace(itsFile, dataForkBytes, rsrcForkBytes);
  161. } // TContainerDocument::DoNeedDiskSpace 
  162.  
  163. //----------------------------------------------------------------------------------------
  164. // TContainerDocument::DoMenuCommand:
  165. //----------------------------------------------------------------------------------------
  166. #pragma segment ASelCommand
  167.  
  168. void TContainerDocument::DoMenuCommand(CommandNumber aCommandNumber) // Override 
  169. {
  170.     Inherited::DoMenuCommand(aCommandNumber);
  171. } // TContainerDocument::DoMenuCommand 
  172.  
  173. //----------------------------------------------------------------------------------------
  174. // TContainerDocument::DoRead: 
  175. //----------------------------------------------------------------------------------------
  176. #pragma segment AReadFile
  177.  
  178. void TContainerDocument::DoRead(TFile* aFile,
  179.                                        Boolean forPrinting) // Override 
  180. {
  181.     Inherited::DoRead(aFile,forPrinting);
  182. } // TContainerDocument::DoRead 
  183.  
  184. //----------------------------------------------------------------------------------------
  185. // TContainerDocument::DoSetupMenus: 
  186. //----------------------------------------------------------------------------------------
  187. #pragma segment ARes
  188.  
  189. void TContainerDocument::DoSetupMenus() // Override 
  190. {
  191.     Inherited::DoSetupMenus();
  192. } // TContainerDocument::DoSetupMenus 
  193.  
  194. //----------------------------------------------------------------------------------------
  195. // TContainerDocument::DoWrite: 
  196. //----------------------------------------------------------------------------------------
  197. #pragma segment AWriteFile
  198.  
  199. void TContainerDocument::DoWrite(TFile* aFile,
  200.                                     Boolean makingCopy) // Override 
  201. {
  202.     Inherited::DoWrite(aFile,makingCopy);
  203. } // TContainerDocument::DoWrite 
  204.  
  205. //----------------------------------------------------------------------------------------
  206. // End of UContainerDocument.cp
  207.  
  208. #pragma segment Inline
  209.